package com.cxlin.cwanandroid.model.repository

import com.cxlin.base.model.api.BaseRepository
import com.cxlin.cwanandroid.model.api.WanRetrofitClient
import com.cxlin.cwanandroid.model.bean.ArticleList
import com.cxlin.base.model.api.Result

/**
 *
 * @Author: chenxunlin
 * @Date: 2024/4/30 15:05
 */
class CollectRepository : BaseRepository(){

    suspend fun getCollectArticles(page:Int) : Result<ArticleList>{
        return safeApiCall(
            call = {executeResponse(WanRetrofitClient.service.getCollectArticles(page))},
            errorMessage = "网络错误"
        )
    }

    suspend fun collectArticle(articledId:Int) : Result<ArticleList>{
        return safeApiCall(
            call = {executeResponse(WanRetrofitClient.service.collectArticle(articledId))},
            errorMessage = "网络错误"
        )
    }

    suspend fun unCollectArticle(articledId:Int) : Result<ArticleList>{
        return safeApiCall(
            call = {executeResponse(WanRetrofitClient.service.cancelCollectArticle(articledId))},
            errorMessage = "网络错误"
        )
    }
}